package copyengine.dataLayer.rpc.moudle.errorHandle
{
	import flash.display.Sprite;

	public class CERpcErrorHandleManger implements ICERpcErrorHandleModule
	{
		private var isAlreadyPopDialog:Boolean;

		private var errorPanel:IErrorPanel;
		private var errorLayer:Sprite;

		public function CERpcErrorHandleManger(_errorLayer:Sprite,
											   _errorPanel:IErrorPanel)
		{
			errorLayer = _errorLayer;
			errorPanel = _errorPanel;
		}

		public function sendRequestFailedErrorFlow():void
		{
			errorPanel && showErrorPanel();
		}

		public function analyseServerDataFailedErrorFlow():void
		{
			errorPanel && showErrorPanel();
		}

		private function showErrorPanel():void
		{
			errorLayer.graphics.beginFill(0, 0);
			errorLayer.graphics.drawRect(0, 0, errorLayer.stage.stageWidth, errorLayer.stage.stageHeight);
			errorLayer.graphics.endFill();

			errorPanel.initialize();
			errorLayer.addChild(errorPanel.getContainer());
			errorPanel.getContainer().x = errorLayer.stage.stageWidth >> 1;
			errorPanel.getContainer().y = errorLayer.stage.stageHeight >> 1;
		}

	}
}
